import { Component, OnInit, Input } from "@angular/core";

@Component({
  selector: "app-branch-sheet",
  templateUrl: "./branch-sheet.component.html",
  styleUrls: ["./branch-sheet.component.scss"]
})
export class BranchSheetComponent implements OnInit {
  @Input() tagData: any;
  // 显示展开
  openFlag = true;
  // 列表
  dataList: any = [];
  // 显示数据
  showList: any = [];

  constructor() {}

  ngOnInit() {
    this.dataList = this.tagData.data.data;
    this.showList = this.dataList.slice(0, this.tagData.shrink ? this.tagData.shrink : 1);
  }

  showHide() {
    if (this.openFlag) {
      this.showList = this.dataList.slice(0, this.tagData.expand ? this.tagData.expand : 2);
    } else {
      this.showList = this.dataList.slice(0, this.tagData.shrink ? this.tagData.shrink : 1);
    }
    this.openFlag = !this.openFlag;
  }
}
